package wash

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserWashDescInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 洗码页面--洗码描述
func NewUserWashDescInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserWashDescInfoLogic {
	return &UserWashDescInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserWashDescInfoLogic) UserWashDescInfo(req *types.UserWashDescRequest) (resp *types.UserWashDescResponse, err error) {
	userWashDesc, err := l.svcCtx.AssetsRpc.UserWash.LastUserWashDesc(l.ctx, &rpc.LastUserWashDescRequest{Language: req.Language})
	if err != nil {
		return nil, err
	}

	resp = &types.UserWashDescResponse{
		Id:          userWashDesc.Data.Id,
		Status:      userWashDesc.Data.Status,
		Language:    userWashDesc.Data.Language,
		Description: userWashDesc.Data.Description,
		CreatedAt:   userWashDesc.Data.CreatedAt,
		UpdatedAt:   userWashDesc.Data.UpdatedAt,
	}
	return
}
